package com.lc.boxuegu.M_LRUCache;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author zhaiyj
 * @date 2025/6/9 20:51
 */
public class LRUCache1 extends LinkedHashMap<Integer, Integer> {

    private static final float DEFAULT_LOAD_FACTOR = 0.75f;

    private final int capacity;


    public LRUCache1(int capacity) {
        super(capacity, DEFAULT_LOAD_FACTOR, true);
        this.capacity = capacity;
    }

    public int get(int key){
        return super.get(key);
    }

    @Override
    protected boolean removeEldestEntry(Map.Entry<Integer, Integer> eldest) {
        return size() > capacity;
    }
}
